package com.chaos.framework.model.dto.result.list;

import com.chaos.framework.model.enums.ResultEnum;
import com.chaos.framework.model.dto.result.Result;
import lombok.*;
import lombok.experimental.Accessors;

import java.util.List;

/**
 * @author Jacky
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class ListResult<T> extends Result {

    /**
     * 响应数据
     */
    private List<T> list;

    public ListResult(ResultEnum re, List<T> list) {
        this.setCode(re.getCode());
        this.setMsg(re.getMsg());
        this.setList(list);
    }

    public ListResult(Integer code, String msg, List<T> list) {
        this.setCode(code);
        this.setMsg(msg);
        this.setList(list);
    }


    public static <T> ListResult<T> ok(List<T> list) {
        return new ListResult(ResultEnum.OK.getCode(), "SUCCESS", list);
    }

}
